import {
    cateListApi
} from '@/api/cate'
import {
    Message
} from 'element-ui'
export default {
    namespaced: true,
    state: {
        // 一、二、三级的分类树列表
        allCateTreeList: []
    },
    mutations: {
        // 更改数据
        setAllCateTreeList(state, list) {
            state.allCateTreeList = list
        }
    },
    actions: {
        // 获取数据
        async getAllCateList(context) {
            const res = await cateListApi({
                type: 3
            })
            if (res.meta.status !== 200) {
                return Message.error('获取数据失败')
            }
            context.commit('setAllCateTreeList', res.data.result)
        }
    }
}